package dongze.com.ckdj.adapter;

import android.databinding.DataBindingUtil;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import java.text.SimpleDateFormat;
import java.util.List;

import dongze.com.ckdj.R;
import dongze.com.ckdj.data.entity.response.GetCheckInRecordResponse;
import dongze.com.ckdj.data.entity.response.GetNamePlateWorkLoadResponse;
import dongze.com.ckdj.databinding.CheckInWorkLoadListItemBinding;
import dongze.com.ckdj.databinding.NamePlateWorkLoadListItemBinding;
import dongze.com.ckdj.databinding.model.CheckInWorkLoadListItemModel;
import dongze.com.ckdj.databinding.model.NamePlateWorkLoadListItemModel;

/**
 * Created by fanqwz on 2017/9/5.
 */

public class CheckInWorkLoadListAdapter extends BaseAdapter {
    List<GetCheckInRecordResponse.GetCheckInRecordItem> data;

    public void setData(List<GetCheckInRecordResponse.GetCheckInRecordItem> data) {
        this.data = data;
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return data == null ? 0 : data.size();
    }

    @Override
    public Object getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            CheckInWorkLoadListItemBinding binding = DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()), R.layout.check_in_work_load_list_item, parent, false);
            convertView = binding.getRoot();
            binding.setCheckInWorkLoadListItem(new CheckInWorkLoadListItemModel());
            convertView.setTag(binding.getCheckInWorkLoadListItem());
        }

        CheckInWorkLoadListItemModel model = (CheckInWorkLoadListItemModel) convertView.getTag();
        model.vin.set(data.get(position).getVin());
        model.brand.set(data.get(position).getBrand_name());
        return convertView;
    }
}
